home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / TEMPLATE.ZIP / TEMPL.C < prev    next >
C/C++ Source or Header  |  1994-03-03  |  4KB  |  145 lines

  1. /***********************************************************************
  2.  
  3. Routine Name:           Windows Application Template
  4.  
  5. Source Filename:        TEMPL.C
  6.  
  7. Date:                   
  8.  
  9. Programmer:             
  10.  
  11. Modification Log:       
  12.  
  13. Description:
  14.  
  15. ************************************************************************/
  16.  
  17. #include "templ.h"
  18.  
  19. char       szAppName[]     = "WINTEMPL";
  20. char       FullAppName[]   = "Windows Application Template";
  21.  
  22.  
  23.  
  24. int PASCAL WinMain (HANDLE hInstance, HANDLE hPrevInstance,
  25.                     LPSTR lpszCmdLine, int nCmdShow)
  26. {
  27.    HWND        hwnd;
  28.    MSG         msg;
  29.    WNDCLASS    wndclass;
  30.    HANDLE      hAccel;
  31.  
  32.    if (!hPrevInstance)
  33.    {
  34.       wndclass.style          = CS_HREDRAW | CS_VREDRAW;
  35.       wndclass.lpfnWndProc    = WndProc;
  36.       wndclass.cbClsExtra     = 0;
  37.       wndclass.cbWndExtra     = DLGWINDOWEXTRA;
  38.       wndclass.hInstance      = hInstance;
  39.       wndclass.hIcon          = LoadIcon (hInstance, szAppName);
  40.       wndclass.hCursor        = LoadCursor (NULL, IDC_ARROW);
  41.       wndclass.hbrBackground  = COLOR_WINDOW + 1;
  42.       wndclass.lpszMenuName   = NULL;
  43.       wndclass.lpszClassName  = "WINTEMPL";
  44.  
  45.       RegisterClass (&wndclass);
  46.    }
  47.  
  48.    hwnd = CreateDialog (hInstance, szAppName, 0, NULL);
  49.  
  50.    ShowWindow (hwnd, nCmdShow);
  51.  
  52.    hAccel = LoadAccelerators( hInstance, szAppName );
  53.  
  54.    while (GetMessage (&msg, NULL, 0, 0))
  55.    {
  56.       if( !TranslateAccelerator( hwnd, hAccel, &msg ) )
  57.       {
  58.          TranslateMessage (&msg);
  59.          DispatchMessage (&msg);
  60.       }
  61.    }
  62.    return msg.wParam;
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69. long FAR PASCAL _export WndProc (HWND hwnd, UINT message,
  70.                                  UINT wParam, LONG lParam)
  71. {
  72.    static FARPROC lpfnAboutBox;
  73.    static HANDLE  hInstance;
  74.  
  75.    char buffer[256];
  76.  
  77.    switch (message)
  78.    {
  79.       case WM_CREATE:
  80.            hInstance = ( (LPCREATESTRUCT) lParam)->hInstance;
  81.            lpfnAboutBox = MakeProcInstance( (FARPROC) AboutBox, hInstance );
  82.            return 0;
  83.  
  84.  
  85.       case WM_COMMAND:
  86.            switch( wParam )
  87.            {
  88.              case IDM_FILENEW:
  89.              case IDM_FILEOPEN:
  90.              case IDM_FILESAVE:
  91.              case IDM_FILESAVEAS:
  92.              case IDM_FILEPRINT:
  93.              case IDM_FILEPAGESETUP:
  94.              case IDM_FILEPRINTSETUP:
  95.  
  96.              case IDM_EDITUNDO:
  97.              case IDM_EDITCUT:
  98.              case IDM_EDITCOPY:
  99.              case IDM_EDITPASTE:
  100.              case IDM_EDITDELETE:
  101.                   MessageBox( hwnd, (LPSTR) "Function Not Yet Implemented.",
  102.                               (LPSTR) FullAppName,
  103.                               MB_ICONINFORMATION | MB_OK );
  104.                   return( 0 );
  105.  
  106.              case IDM_HELPCONTENTS:
  107.                   WinHelp( hwnd, (LPSTR) "TEMPL.HLP",
  108.                            HELP_CONTENTS, 0L );
  109.                   return( 0 );
  110.  
  111.              case IDM_HELPSEARCH:
  112.                   strcpy( buffer, "" );
  113.                   WinHelp( hwnd, (LPSTR) "TEMPL.HLP",
  114.                            HELP_PARTIALKEY, (DWORD) (LPSTR) buffer );
  115.                   return( 0 );
  116.  
  117.              case IDM_HELPHELP:
  118.                   WinHelp( hwnd, (LPSTR) "TEMPL.HLP",
  119.                            HELP_HELPONHELP, 0L );
  120.                   return( 0 );
  121.  
  122.              case IDM_FILEEXIT:
  123.                   SendMessage( hwnd, WM_CLOSE, 0, 0L );
  124.                   return( 0 );
  125.  
  126.              case IDM_HELPABOUT:
  127.                   if( DialogBox( hInstance, "ABOUTBOX",
  128.                                  hwnd, lpfnAboutBox ) );
  129.                      InvalidateRect( hwnd, NULL, TRUE );
  130.                   return( 0 );
  131.  
  132.            }
  133.            break;
  134.  
  135.       case WM_CLOSE:
  136.            DestroyWindow( hwnd );
  137.            return 0;
  138.  
  139.       case WM_DESTROY:
  140.            PostQuitMessage (0);
  141.            return 0;
  142.    }
  143.    return DefWindowProc (hwnd, message, wParam, lParam);
  144. }
  145.